// 查看是哪个班级的详情的时候需要使用到

import { defineStore } from 'pinia'
import { ref } from 'vue'
import { getClazzDetail } from '@/api/clazz'
export const useClazzDetailStore = defineStore('clazz', () => {
  const clazz_name = ref('')
  const clazz_id = ref('')
  const setClazzName = (name) => {
    clazz_name.value = name
  }
  const setClazzId = (id) => {
    clazz_id.value = id
  }
  const getClazzDetailPinia = async (id) => {
    try {
      const res = await getClazzDetail(id)
      setClazzName(res.data.info.name)
      return { success: true, data: res.data }
    } catch (error) {
      return { success: false, error: error.message }
    }
  }
  return {
    clazz_name,
    clazz_id,
    setClazzName,
    setClazzId,
    getClazzDetailPinia
  }
})

